#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
ll a[12];
int main()
{
    IOS;
    string s;
    cin>>s;
    ll len=s.length();
    for(ll i=0;i<len;i++){
        a[i]=s[i]-'0';
    }
    sort(a,a+len);
    do{
        for(ll i=0;i<len;i++)cout<<a[i];
        cout<<endl;
    }while(next_permutation(a,a+len));
    getchar();
    getchar();
    return 0;
}
